package com.ht.ui.report;

import com.ht.aems.fesmodel.HisDataProvider;
import com.ht.aems.fesmodel.data.MeasurePoint;
import com.ht.aems.fesmodel.persist.HisDataSqlPersist;

import java.net.URL;
import java.util.Date;
import java.util.Map;

/**
 * Created by IntelliJ IDEA.
 * User: Dong Shufeng
 * Date: 11-10-29
 */
public abstract class AbstractAnalogJRMaker extends AbstractJrMaker {
    protected int mode;
    protected HisDataProvider hisDataProvider = new HisDataSqlPersist();
    protected Map<Integer, Double> nId2Values;

    public AbstractAnalogJRMaker() {
    }

    public AbstractAnalogJRMaker(int mode) {
        this.mode = mode;
    }

    public AbstractAnalogJRMaker(URL resource, int mode) {
        super(resource);
        this.mode = mode;
    }

    protected AbstractAnalogJRMaker(int mode, HisDataProvider hisDataProvider) {
        this.mode = mode;
        this.hisDataProvider = hisDataProvider;
    }

    protected AbstractAnalogJRMaker(URL resource, int mode, HisDataProvider hisDataProvider) {
        super(resource);
        this.mode = mode;
        this.hisDataProvider = hisDataProvider;
    }

    public void loadValueFormDB(int[] nids, Date date) {
        if (mode == MeasurePoint.DAY) {
            nId2Values = hisDataProvider.getDayAnalog(nids, date);
        } else if (mode == MeasurePoint.MONTH) {
            nId2Values = hisDataProvider.getMonthAnalog(nids, date);
        } else if (mode == MeasurePoint.YEAR) {
            nId2Values = hisDataProvider.getYearAnalog(nids, date);
        }
    }

    public void setMode(int mode) {
        this.mode = mode;
    }

    public void setHisDataProvider(HisDataProvider hisDataProvider) {
        this.hisDataProvider = hisDataProvider;
    }
}
